--require("../proto/protobuf");
local AglorithmInterface = require("aglorithminterface");
local instance = AglorithmInterface.getInstance();
local Cards = require(basePath .. "domain/cards");
local DdzCard = require(basePath .. "domain/ddzcard")
local M = {};



-- - "dddd->" = {
-- -     "cardarray" = {
-- -         1 = {
-- -             "cardList" = {
-- -                 1 = {
-- -                     "card" = 0
-- -                     "cardvalue" = 0
-- -                     "number"    = 3
-- -                 }
-- -             }
-- -             "cardtype" = 1
-- -         }
-- -         2 = {
-- -             "cardList" = {
-- -                 1 = {
-- -                     "cardshape" = 0
-- -                     "cardvalue" = 0
-- -                     "number"    = 4
-- -                 }
-- -             }
-- -             "cardtype" = 1
-- -         }
-- -     }
-- -     "cmd"       = "compare"
-- - }


function M.compare(msg)
	local cardsList = {} ;
	for _,v in ipairs(msg.cardarray) do
		local cards = instance:getOutCards(v.cardList);
		dump(cards,"cards->")
		print();
		if v.cardtype ~= cards:getResult():getType().type then --没有赋值类型
			print("类型不一致,重新赋值");
		end
		table.insert(cardsList,cards);
	end
    return cardsList[1]:compareTo(cardsList[2]);
end


-- function M.decodeParaMsg( data )
-- 	local paraMsgReq = server_arithmetic_pb.ParaMsg();
-- 	paraMsgReq.parseString(data);

-- 	local info = {};
-- 	info.cardList = {};
-- 	for k, v in ipairs(paraMsgReq.cardList) do 
-- 		local cardInfoList = {};
-- 		cardInfoList.cards = {};
-- 		for kk, vv in ipairs(v.cards) do 
-- 			local card = {};
-- 			card.value = vv.value;
-- 			card.number = vv.number;
-- 			card.shape = vv.shape;
-- 			card.isLaizi = vv.isLaizi; 
-- 			card.laiziNumber = vv.laiziNumber;
-- 			table.insert(cardInfoList.cards, card);
-- 		end
-- 		cardInfoList.type = v.type;
-- 		table.insert(info.cardList, cardInfoList);
-- 	end

-- 	info.suitType = paraMsgReq.suitType;
-- 	info.suitTerm = paraMsgReq.suitTerm;
-- 	info.desc = paraMsgReq.desc;

-- 	return info;
-- end

-- function M.checkOutcardValid( data )
-- 	-- 获取C++传过来的数据
-- 	local paraMsgReq = M.decodeParaMsg(data);

-- 	-- local result = AglorithmInterface.getInstance():checkOutcardValid(lastOutcardType,lastOutcard, currentOutcard);

-- 	local result = {};
-- 	for i = 1, 10 do 
-- 		local tempCard = {} ;
-- 		tempCard.number = math.random(1, 15);
-- 		tempCard.shape = math.random(1, 4);
-- 		tempCard.value = 1;
-- 		table.insert(tempData,tempCard);
-- 	end

-- 	local paraMsg = server_arithmetic_pb.ParaMsg();
-- 	local cardList = server_arithmetic_pb.CardList();
-- 	for k, v in ipairs(result or {}) do 
-- 		local cardInfo = server_arithmetic_pb.CardInfo();
-- 		cardInfo.number = v.number;
-- 		cardInfo.shape = v.shape;
-- 		cardInfo.value = v.value;

-- 		table.insert(cardList, cardInfo);
-- 	end

-- 	table.insert(paraMsg.cardList, cardList);

-- 	return paraMsg:SerializeToString();
-- end

return M;